"""author: wenyao
   data: 2021/12/14
   project: cjh
"""
# class A:
#     pass
# a = A()
# print(type(a))
# print(type(A))

#python中一切皆对象， 类也是对象， 类也是由另外一个类创建的

#type： 创建类的类，称之为元类

# class Animal:
#     def __init__(self, name):
#         self.name = name
#
#     def eat(self):
#         print("i am eating....")

# def init(self, name):
#     self.name = name
# def eat(self):
#     print("i am eating...")

#            名字（str）  基类（元组）   方法属性（dict）
# Animal = type("Animal", (object,), {"__init__":init, "eat":eat, "name1":"sc1"})
# a1 = Animal("sc")
# a1.eat()
# print(a1.name, a1.name1)

#元类  -- type
#自定义元类 -- 继承type
# class MyMate(type):
#     #pass
#     def  __new__(cls, name, bases, attrs):
#         attrs["test"] = "mymate test"
#         if "foo" not in attrs:
#             raise TypeError("必须设置foo属性！")
#         # attrs["test"] = "mymate test"
#         return type.__new__(cls, name, bases, attrs)
# class A(metaclass=MyMate):
#     # pass
#     foo = "foo......."
# a = A()
# print(a.test)
# print(type(A))

#type  object
#面向对象里面有两种关系
#1、继承关系  object是所有类的父类，是最顶层的类
#2、实例与类的关系（创建关系）  type是最顶层的类

# print(type(object))
# print(type(type))
# print(object.__bases__)
# print(type.__bases__)
#
# object = type(object)
#相当于一种鸡生蛋，蛋生鸡的关系，  先有鸡还是先有蛋